package com.andy.buyu.server.dto;

import com.andy.buyu.server.entity.UsrGameLog;
import com.andy.buyu.server.game.GameConf;
import com.andy.buyu.server.game.GameUser;

import io.netty.buffer.ByteBuf;

/**
 * 捕鱼202
 * @author cuiwm
 */
public class CatchMessage extends BaseMessage{
	
    private UsrGameLog log;
    private int bullet;
    private GameUser gameUser;
    
    public CatchMessage(UsrGameLog log,int bullet, GameUser gameUser) {
    	this.log = log;
    	this.bullet = bullet;
    	this.gameUser = gameUser;
	}

	@Override
	public void writeBody(ByteBuf buf) {
		writeString(buf, log.getUid().toString());
		buf.writeByte(bullet);
		buf.writeInt(log.getScriptId());
		buf.writeInt(log.getAddCoin());
		buf.writeInt(log.getRate());
		buf.writeInt(log.orate());
		buf.writeInt(log.yrate());
		
		if(gameUser == null) {
			buf.writeByte(0);
			buf.writeInt(0);
			buf.writeByte(0);
		}else {
			buf.writeByte(gameUser.getLastShell());
			buf.writeInt(GameConf.getSpecialBullet(gameUser.getLastShell()).getLimitTime());
			buf.writeByte(gameUser.getLastShellNum());
		}
	}


}